package com.ruoyi.app.controller;

import com.ruoyi.business.service.ISysConfigAppService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.$;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.app.interceptor.VersionLocalinterceptor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 参数配置 信息操作处理
 * 
 * @author ruoyi
 */
@Tag(name = "参数配置")
@RestController
@RequestMapping(VersionLocalinterceptor.version+"/system/config")
public class SysConfigControllerAdmin extends BaseController
{
    @Autowired
    private ISysConfigAppService configService;

    /**
     * 根据参数编号获取详细信息
     */
    @Operation(summary = "根据参数编号获取详细信息")
    @GetMapping(value = "/{configId}")
    public $ getInfo(@PathVariable Long configId)
    {
        return $.success(configService.selectConfigById(configId));
    }

    /**
     * 根据参数键名查询参数值
     */
    @Operation(summary = "根据参数键名查询参数值")
    @GetMapping(value = "/configKey/{configKey}")
    public $ getConfigKey(@PathVariable String configKey)
    {
        return $.success(configService.selectConfigByKey(configKey));
    }

    /**
     * 刷新参数缓存
     */
    @Operation(summary = "刷新参数缓存")
    @Log(title = "参数管理", businessType = BusinessType.CLEAN)
    @DeleteMapping("/refreshCache")
    public $ refreshCache()
    {
        configService.resetConfigCache();
        return $.success();
    }
}
